package com.jkgl.executor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@EnableAsync
@Configuration
@Deprecated
/**
 * 线程池用不到
 * 消息逐个读取
 * 并非多数据
 */
public class StreamExecutorPool {

    private static final Integer CORE_POOL_SIZE=2;
    private static final Integer MAX_POOL_SIZE=4;
    private static final Integer KEEP_ALIVE_SECONDS=20;
    private static final Integer QUEUE_CAPACITY=800;



    @Bean("NOTICE")
    public ThreadPoolTaskExecutor threadPoolTaskExecutorNotice(){
        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
        threadPoolTaskExecutor.setCorePoolSize(CORE_POOL_SIZE);
        threadPoolTaskExecutor.setMaxPoolSize(MAX_POOL_SIZE);
        threadPoolTaskExecutor.setKeepAliveSeconds(KEEP_ALIVE_SECONDS);
        threadPoolTaskExecutor.setQueueCapacity(QUEUE_CAPACITY);
        return threadPoolTaskExecutor;
    }

    @Bean("ERROR")
    public ThreadPoolTaskExecutor threadPoolTaskExecutorError(){
        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
        threadPoolTaskExecutor.setCorePoolSize(CORE_POOL_SIZE);
        threadPoolTaskExecutor.setMaxPoolSize(MAX_POOL_SIZE);
        threadPoolTaskExecutor.setKeepAliveSeconds(KEEP_ALIVE_SECONDS);
        threadPoolTaskExecutor.setQueueCapacity(QUEUE_CAPACITY);
        return threadPoolTaskExecutor;
    }


    @Bean("INFORMATION")
    public ThreadPoolTaskExecutor threadPoolTaskExecutorInformation(){
        ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
        threadPoolTaskExecutor.setCorePoolSize(CORE_POOL_SIZE);
        threadPoolTaskExecutor.setMaxPoolSize(MAX_POOL_SIZE);
        threadPoolTaskExecutor.setKeepAliveSeconds(KEEP_ALIVE_SECONDS);
        threadPoolTaskExecutor.setQueueCapacity(QUEUE_CAPACITY);
        return threadPoolTaskExecutor;
    }
}
